package createPattern.builder;

import createPattern.factory.model.Size;
import createPattern.factory.model.Sugar;
import createPattern.factory.model.Temp;

public class MilkTea {

    private final String type;
    private final Size size;
    private final Temp temp;
    private final Sugar sugar;

    private MilkTea(Builder builder) {
        type = builder.type;
        size = builder.size;
        temp = builder.temp;
        sugar = builder.sugar;
    }

    public String getType() {
        return type;
    }

    public Size getSize() {
        return size;
    }

    public Temp getTemp() {
        return temp;
    }

    public Sugar getSugar() {
        return sugar;
    }

    public void show() {
        System.out.println("这是一杯" + size.getName() + "、" + temp.getName() + "、" + sugar.getName() + "的" + type);
    }
    public static class Builder {
        private final String type;
        private Size size = Size.TALL;
        private Temp temp = Temp.WARM;
        private Sugar sugar = Sugar.MORE;

        public Builder(String type) {
            this.type = type;
        }

        public Builder size(Size size) {
            this.size = size;
            return this;
        }

        public Builder temp(Temp temp) {
            this.temp = temp;
            return this;
        }

        public Builder sugar(Sugar sugar) {
            this.sugar = sugar;
            return this;
        }

        public MilkTea build() {
            return new MilkTea(this);
        }
    }
}
